package org.tio.sitexxx.service.service.qj;

import com.alibaba.fastjson.JSON;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.SqlPara;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tio.sitexxx.service.model.main.Payment;
import org.tio.sitexxx.service.vo.Const;

import java.util.Map;

public class PaymentService  {

    private static Logger log	= LoggerFactory.getLogger(PaymentService.class);
    public static final PaymentService me	= new PaymentService();
    public static String sqlid1 = "payment.getPayment";
    public static String db1 = Const.Db.TIO_SITE_MAIN;
    final Payment dao	= new Payment().dao();

    public Payment getPayment(Map<String,Object> query){
        Kv cond = Kv.create().set(query);
        SqlPara sqlPara1 = Db.use(db1).getSqlPara(sqlid1,cond);
        System.out.println(JSON.toJSONString(sqlPara1));
        Record record= Db.use(db1).findFirst(sqlPara1);
        Map <String,Object> resultmap=record.getColumns();

        Payment payment=JSON.parseObject(JSON.toJSONString(resultmap),Payment.class);
        return payment;
    }
    public void createPayment(Payment payment){
        payment.save();
    }
    public boolean update(Payment query){
        return query.update();
    }

}
